#include "../include/rpc_server.h"
#include "../include/conf_reader.h"

void rpc_server::start()
{
    server=build.BuildAndStart();
    server->Wait();
    
}

void rpc_server::stop()
{
    server->Shutdown();

}

rpc_server::rpc_server(){
    std::string ip_port=conf_reader::get_conf_reader_instance()->get_value_from_key("statusServer_address","192.168.174.139:10000");
    build.AddListeningPort(ip_port,grpc::InsecureServerCredentials());
    //注册服务
    register_service();
}


void rpc_server::register_service()
{
    status_service=new statusServe_rpc();
    build.RegisterService(status_service);
}

rpc_server::~rpc_server()
{
    //销毁掉注册的服务
    delete status_service;
}